package org.aplikator.client.descriptor;

import java.util.Date;

import org.aplikator.client.widgets.DateFieldWidget;
import org.aplikator.client.widgets.FormWidget;

import com.google.gwt.user.client.ui.Widget;

@SuppressWarnings("serial")
public class DateFieldDTO implements WidgetDTO {

    private PropertyDTO<Date> property;

    private boolean labelAbove = false;

    @SuppressWarnings("unused")
    private DateFieldDTO() {
    }

    public DateFieldDTO(PropertyDTO<Date> property) {
        this.property = property;
    }

    public Widget getWidget(FormWidget form) {
        DateFieldWidget field = new DateFieldWidget(property.getLocalizedName(), property, labelAbove);
        if (property.getRefferedThrough() != null) {
            field.setEnabled(false);
        }
        form.registerDataField(field);
        return field;
    }

    public boolean isLabelAbove() {
        return labelAbove;
    }

    public void setLabelAbove(boolean labelAbove) {
        this.labelAbove = labelAbove;
    }

}
